//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.yang.newcustomcuilian.listeners;

import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent;

public class HealthFixListener implements Listener {
    public HealthFixListener() {
    }

    @EventHandler
    public void Health(EntityRegainHealthEvent event) {
        if (event.getEntity() instanceof Player) {
            Player player = (Player)event.getEntity();
            double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
            double currentHealth = player.getHealth() + event.getAmount();
            if (currentHealth > maxHealth) {
                player.setHealth(30D);
            }
        }

    }
}
